﻿@model IEnumerable<GSLMS.Entity.TB_APP_PROINFO>
@{
    Layout = null;
    ViewBag.ViewTitle = "立项申请";
    int i = 1;
    var SearchParma = ViewData["SearchParma"] as GSLMS.Entity.TB_APP_PROINFO ?? new GSLMS.Entity.TB_APP_PROINFO();
    var ddlProStatus = ViewData["ProStatus"] as SelectList;
    var ddlProduct = ViewData["Product"] as SelectList;
    var ddlSource = ViewData["Source"] as SelectList;

    //SearchParma.APPDATE = DateTime.Now.AddMonths(-1);
    //SearchParma.APPDATE_END = DateTime.Now;    
}
<form id="pagerForm" method="get" action="DianDang/Apply/ProInfo/index?action=page&OpID=@ViewData["OperateID"]">
<input type="hidden" name="pageNum" value="1" />
<input type="hidden" name="numPerPage" value="@ViewData["pageSize"]" />
<input type="hidden" name="RowCount" value="@ViewData["RowCount"]" />
<input type="hidden" name="CUSTNAME" value="@SearchParma.CUSTNAME" />
<input type="hidden" name="REGDATE" value="@SearchParma.APPDATE" />
<input type="hidden" name="REGDATE_END" value="@SearchParma.APPDATE_END" />
<input type="hidden" name="STATUS" value="@SearchParma.STATUS" />
</form>
<div class="pageHeader">
    <script>
    $(function () { 
    var $this=$("#Form_@ViewData["CurrentController"]");
    $this.find("#Status").val("@SearchParma.STATUS");
    $this.find("#ProductName").val("@SearchParma.PRODUCTNAME");
    
    });
    </script>
    <form onsubmit="return navTabSearch(this)" id="Form_@ViewData["CurrentController"]" action="DianDang/Apply/ProInfo/index?action=search&OpID=@ViewData["OperateID"]"
    method="post">
    <div class="searchBar">
        <table class="searchContent">
            <tr>
                <th>
                    客户名称：
                </th>
                <td>
                    @Html.TextBox("CUSTNAME", SearchParma.CUSTNAME, new { @style="width:100px;"})
                </td>
                <th>
                    手机：
                </th>
                <td>
                    @Html.TextBox("CONTRACTTEL", SearchParma.CONTRACTTEL, new { @style = "width:100px;" })
                </td>
                <th>
                    状态:
                </th>
                <td>
                    @Html.DropDownList("Status", ddlProStatus, GSLMS.WebAPP.HelperCommon.SelectDefaultValue, new { @style = "width:90px;" })
                </td>
                <th>
                    申请日期：
                </th>
                <th>
                    @Html.TextBox("APPDATE", SearchParma.APPDATE, new { @class = "date", @style = "width:70px;", format = "yyyy-MM-dd", @maxDate = "%y-%M-%d", @readonly = "true", formatDate = "yyyy-MM-dd" })
                </th>
                <th>
                    ~
                    @Html.TextBox("APPDATE_END", SearchParma.APPDATE_END, new { @class = "date", @style = "width:70px;", format = "yyyy-MM-dd", @maxDate = "%y-%M-%d", @readonly = "true", formatDate = "yyyy-MM-dd" })
                </th>
            </tr>
            <tr>
                <th>
                    产品:
                </th>
                <td>
                    @Html.DropDownList("ProductName", ddlProduct, GSLMS.WebAPP.HelperCommon.SelectDefaultValue, new {@style = "width:90px;"})
                </td>
                <th>
                    来源渠道:
                </th>
                <td>
                    @Html.DropDownList("Source", ddlSource, GSLMS.WebAPP.HelperCommon.SelectDefaultValue, new { @selectedvalue = SearchParma.SOURCE, @style = "width:90px;" })
                </td>
                <th>
                    处理状态:
                </th>
                <td>
                    <select id="FlowStatus" name="FlowStatus" style="width:80px"  selectedvalue ="@SearchParma.FLOWSTATUS">
                        <option value="-1">-----请选择----</option>
                        <option value="0">待处理</option>
                        <option value="1">已处理</option>
                    </select>
                </td>
                <td align="right">
                    <div class="subBar">
                        <ul>
                            <li>
                                <div class="buttonActive">
                                    <div class="buttonContent">
                                        <button type="submit" name="submit">
                                            检索</button></div>
                                </div>
                            </li>
                            <li>
                                <div class="buttonActive">
                                    <div class="buttonContent">
                                        <button type="reset" name="reset">
                                            重置</button></div>
                                </div>
                            </li>
                        </ul>
                    </div>
                </td>
            </tr>
        </table>
    </div>
    </form>
</div>
<div class="pageContent">
    @Html.Partial("Buttons")
    <table class="list" layouth="130" id="tableProInfoList">
        <thead>
            <tr class="header">
                <th style="width:80px;">
                    申请编号
                </th>
                <th style="width:135px;">
                    客户名称
                </th>
                <th style="width:100px;">
                    申请日期
                </th>
                <th style="width:80px;">
                    贷款产品
                </th>
                <th style="width:100px;">
                    申请金额(万元)
                </th>
                <th style="width:70px;">
                    期限
                </th>
                <th style="width:80px;">
                    来源渠道
                </th>
                <th style="width:80px;">
                    项目经理
                </th>
                <th style="width:80px;">
                    状态
                </th>
            </tr>
        </thead>
        @foreach (var item in Model)
        {            
            <tr target="ProInfo_id" rel="@item.ID" RegID="@item.REGINFOID" BUSSTYPE="@item.BUSSTYPE" STATUS="@item.STATUS">
                <td>
                    @item.APPLYNO
                </td>
                <td>
                    @item.CUSTNAME
                </td>
                <td style="text-align:center">
                    <span formatdate="yyyy-MM-dd">@item.APPDATE</span>
                </td>
                <td style="text-align:center">
                    @item.PRODUCTNAME
                </td>
                <td style="text-align: right;">
                    @item.AMOUNT
                </td>
                <td style="text-align:center">
                    @item.LOANPHASE<span>@((GSLMS.Entity.Enum.ApplyEnum.RegLoanPhaseType)item.LOANPHAESTYPE)</span>
                </td>
                <td style="text-align:center">
                    @item.SOURCE
                </td>
                <td style="text-align:center">
                    @item.SALESMAN
                </td>
                <td style="text-align: center;">
                    @((GSLMS.Entity.Enum.ApplyEnum.ProStatus)item.STATUS)
                </td>
            </tr>
            i += 1;
        }
    </table>
</div>
@Html.Partial("PageBar")
<script>
    function UpdateProInfo(obj) {
        $this = $(obj);
        var id = $("#tableProInfoList").find(".selected").attr("rel");
        if (id) {
            var STATUS = $("#tableProInfoList").find(".selected").attr("STATUS");
            if (STATUS == 10) {
                var BussType = $("#tableProInfoList").find(".selected").attr("BUSSTYPE");
                var url = "DianDang/Apply/ProInfo/Create/" + id;
                var title = "编辑立项申请"
                var rel = "DianDang_Apply_ProInfo_3";
                var options = {};
                if (BussType && BussType == 3) {
                    title = "编辑立项申请--赎楼";
                    url = "DianDang/Apply/ProInfo/CreateHouInfo/" + id;
                }
                $.pdialog.open(url, rel, title, options);
            }
            else
            { alertMsg.error("已提交的立项申请不可编辑"); }
        }
        else {
            alertMsg.error("请选择一条记录");
        }
    }

    function GetProReportInfo(obj) {
        var $this = $(obj);
        var id = $("#tableProInfoList").find(".selected").attr("rel");
        if (id) {
            var bussType = $("#tableProInfoList").find(".selected").attr("BUSSTYPE");
            var status = $("#tableProInfoList").find(".selected").attr("STATUS");
            if (bussType == 1 || bussType == 2) {
                if (status < 33 && status >= 20) {
                    var rel = $this.attr("rel");
                    var options = {};
                    var title = $this.attr("title");
                    var url = "DianDang/Apply/ProInfo/ReportInfo/" + id;
                    $.pdialog.open(url, rel, title, options);
                }
                else
                { alertMsg.error("此立项申请还没有被审批通过，不允许填写调查报告"); }

            }
            else {
                alertMsg.error("此立项申请不需要填写调查报告");
            }
        }
        else {
            alertMsg.error("请选择一条记录");
        }
        return false;
    }
    function GetSoluConfirm(obj) {
        var $this = $(obj);
        var id = $("#tableProInfoList").find(".selected").attr("rel");

        if (id) {
            var status = $("#tableProInfoList").find(".selected").attr("STATUS");

            if (status < 41)
            { alertMsg.error("未审批同意的立项申请不可点击【方案确认】"); }
            else {
                var rel = $this.attr("rel");
                var options = {};
                var title = $this.attr("title");
                var url = "DianDang/Apply/ProInfo/SoluConfirm/" + id;
                $.pdialog.open(url, rel, title, options);
            }
        }
        else {
            alertMsg.error("请选择一条记录");
        }
        return false;
    }

    function CancelProInfo(obj) {
        var $this = $(obj);
        var id = $("#tableProInfoList").find(".selected").attr("rel");
        if (id) {
            var status = $("#tableProInfoList").find(".selected").attr("STATUS");
            if (status == 5)
            { alertMsg.error("此立项申请已经被取消，不需要再次取消"); }
            else if (status > 60) {
                alertMsg.error("此立项申请已经签定了合同，不允许再取消");
            }
            else {
                var rel = $this.attr("rel");
                var options = {};
                var title = $this.attr("title");
                var url = "DianDang/Apply/ProInfo/Cancel/" + id;
                $.ajax({
                    type: 'POST',
                    url: url,
                    data: {},
                    dataType: "json",
                    cache: false,
                    success: navTabAjaxDone,
                    error: DWZ.ajaxError
                });
            }

        }
        else {
            alertMsg.error("请选择一条记录");
        }
        return false;
    }
</script>
